#include "MethodBinomialSubtraction.h"

using namespace EfficCalcMethods;

RooRealVar MethodBinomialSubtraction::getEfficiency(vector <RooRealVar *> signalVectorProbes, vector <RooRealVar *> backgroundVectorProbes, vector <RooRealVar *> signalVectorSelected, vector <RooRealVar *> backgroundVectorSelected) {
    throw EfficCalcMethodException("For technical reasons, the binomial subtraction method has not yet been implemented, but will be soon");
    if(signalVectorProbes.size()!=1 || signalVectorSelected.size()!=1) {
        throw EfficCalcMethodException("MethodDirect needs at least one signal variable for probes and selected, but was called with "+boost::lexical_cast<string>(signalVectorProbes.size())+" probes variables and "+boost::lexical_cast<string>(signalVectorSelected.size())+" selected variables");
    }
    RooRealVar & nProbes = *signalVectorProbes[0];
    RooRealVar & nSelected = *signalVectorSelected[0];
    float val = nSelected.getVal()/nProbes.getVal();
    float error = sqrt((pow((1-val),2)* pow(nSelected.getError(),2) + pow(val,2)* fabs(pow(nProbes.getError(),2) -  pow(nSelected.getError(),2)))/pow(nProbes.getVal(),2));
    RooRealVar res("efficiency","efficiency",val);
    res.setError(error);
    return res;
}
